home *** CD-ROM | disk | FTP | other *** search
/ ...taking it to the Macs! / ...taking it to the Macs!.iso / Extras / ActiveX Mac SDK / ActiveX SDK / Sample Controls / BDiamond / C3DView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-20  |  4.1 KB  |  127 lines  |  [TEXT/CWIE]

  1. #ifndef __C3DView__
  2. #define __C3DView__
  3. #define __C3DVIEW__
  4.  
  5. //------------------------------------------------------------------------------
  6. //    Constants and enums
  7. //------------------------------------------------------------------------------
  8.  
  9. //    NOTE:    If you add another "Depressed" state to the 3DState enum (and
  10. //            consequently the fColor array), be sure to add it AFTER rstDepressed.
  11. //            If you add another NON-Depressed state, add it BEFORE rstDepressed
  12. //            and slide all the other numbers up one.  This is to allow subclasses
  13. //            to easily detect whether the "button" is "depressed" or not, since
  14. //            they might want to act slightly differently (like drawing overlayed
  15. //            a little down and to the right, to make the button look like it
  16. //            actually gets pressed down).
  17.  
  18. const short kDefaultNumberOf3DViewStates    = 5;
  19. const short kDefaultNumberOf3DViewParts     = 6;
  20.  
  21. extern const  Boolean kIsDeep;
  22. extern const  Boolean kIsNotDeep;
  23.  
  24. extern const  Boolean kIsDepressed;
  25. extern const  Boolean kIsNotDepressed;
  26.  
  27. typedef enum
  28. {
  29. //    NON-Depressed states:
  30.         rstNominal            = 0,    // the "button" is up/off/normal/un-pressed
  31.         rstRed                = 1,    // usually used for "record" modes, warnings, etc
  32.         rstGreen            = 2,    // usually used for optional modes
  33. //    Depressed states:    
  34.         rstDepressed        = 3,    // the "button" is down/on (NOT an emotional state!)
  35.         rstDepressedWhite    = 4        // for "buttons" that light up white when pressed
  36. } E3DState;
  37.  
  38. typedef enum
  39. {
  40.     rptOutsideUpperLeft        = 0,
  41.     rptInsideUpperLeft        = 1,
  42.     rptFill                    = 2,
  43.     rptInsideLowerRight        = 3,
  44.     rptMiddleLowerRight        = 4,
  45.     rptOutsideLowerRight    = 5
  46. } E3DPart;
  47.  
  48.  
  49. //------------------------------------------------------------------------------
  50. //    Class definition
  51. //------------------------------------------------------------------------------
  52.  
  53. class C3DView
  54. {
  55.  
  56.     //    Initialization and cleanup
  57.     public:
  58.         C3DView(E3DState itsInitialState = rstNominal);
  59.         
  60.     //    Drawing
  61.     public:
  62.         virtual void             Draw3D(const DrawContext * context);
  63.         
  64.         virtual void             DrawWithDepth(const DrawContext * context);
  65.         virtual void             DrawWithoutDepth(const DrawContext * context);
  66.  
  67.         virtual void            Invalidate(const DrawContext * context);
  68.                                                                     
  69.     protected:
  70.         virtual short            CheckScreenDepth(const DrawContext * context);    
  71.         
  72.     //    Access
  73.     public:
  74.         virtual E3DState        GetState();
  75.         virtual void            SetState(const DrawContext * context, E3DState theState, Boolean redraw);
  76.         
  77.         virtual Boolean            IsDepressed();
  78.         
  79.     //        The following is a rough legend to the different parts
  80.     //        that are being drawn for a typical C3DView
  81.     //    
  82.     //        -------------------------        -    OutsideUpperLeft
  83.     //        -+++++++++++++++++++++++@        +    InsideUpperLeft
  84.     //        -+********************$%@        
  85.     //        -+********************$%@        *    Fill
  86.     //        -+********************$%@
  87.     //        -+$$$$$$$$$$$$$$$$$$$$$%@        $    InsideLowerRight
  88.     //        -+%%%%%%%%%%%%%%%%%%%%%%@        %    MiddleLowerRight
  89.     //        -@@@@@@@@@@@@@@@@@@@@@@@@        @    OutsideLowerRight
  90.  
  91.     //    Override these methods to change the default drawing behavior.
  92.     protected:
  93.         virtual void    GetOutsideUpperLeftColor(RGBColor * returnColor);
  94.         virtual void    GetInsideUpperLeftColor(RGBColor * returnColor);
  95.  
  96.         virtual void    GetFillColor(RGBColor * returnColor);
  97.  
  98.         virtual void    GetInsideLowerRightColor(RGBColor * returnColor);
  99.         virtual void    GetMiddleLowerRightColor(RGBColor * returnColor);
  100.         virtual void    GetOutsideLowerRightColor(RGBColor * returnColor);
  101.         
  102.     //    Class variables
  103.     public:
  104.         static RGBColor    gColor [ kDefaultNumberOf3DViewStates ] [ kDefaultNumberOf3DViewParts ];
  105.                                                 // this static array is used to
  106.                                                 // get colors for all C3DView
  107.                                                 // instances, unless a subclass has
  108.                                                 // overidden the default drawing
  109.                                                 // behavior and bypassed it.
  110.     
  111.     //    Instance variables
  112.     protected:
  113.         E3DState        mState;                // the state of the view
  114.         Boolean            mIsDeep;            // bit depth, or not?
  115.         Boolean            mIsDepressed;        // is the "button" pressed down?
  116.         
  117. };
  118.  
  119. //----------------------------------------------------------------------------------------
  120. // Global initialization procedure
  121. //----------------------------------------------------------------------------------------
  122.  
  123. extern void InitU3DView(void);
  124.     // Call this routine at initialization time
  125.  
  126. #endif __C3DView__
  127.